package com.zh.zcy.service;

import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

@Component
public class ThreadService {

    @Async("taskExecutor")
    public void sendTask1(){
        try {
            Thread.sleep(5000);
            System.out.println(Thread.currentThread().getName()+"任务1执行完成");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
    @Async("taskExecutor")
    public void sendTask2(){
        try {
            Thread.sleep(7000);
            System.out.println(Thread.currentThread().getName()+"任务2执行完成");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    @Async("taskExecutor2")
    public void sendTask3(){
        try {
            Thread.sleep(10000);
            System.out.println(Thread.currentThread().getName()+"任务3执行完成");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
